<!DOCTYPE html>
<html>
  <head>
    <title>iframe-index.html</title>
	
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="../layui/css/layui.css" type="text/css"></link>
     <link rel="stylesheet" href="../css/manager/iframe-index.css" type="text/css"></link>
     <link rel="stylesheet" href="../css/util/page_head_main.css" type="text/css"></link>
     
       	<script type="text/javascript" src="../js/util/jquery.js"></script>
	<script type="text/javascript" src="../layui/layui.all.js"></script>
  <script type="text/javascript" src="../js/util/rollups/tripledes.js" ></script>
    <script type="text/javascript" src="../js/util/components/mode-ecb.js" ></script>
<script type="text/javascript" src="../js/util/FrameOption.js"></script>
     <!-- <script type="text/javascript" src="http://echarts.baidu.com/examples/vendors/jquery/jquery.js"></script> -->
     <script type="text/javascript" src="../layui/layui.js"></script>
     
     
   <!--   <script src="http://mockjs.com/dist/mock.js"></script> -->
 	 	<script type="text/javascript" src="../js/util/arttemplate.js"></script>
 	<script type="text/javascript" src="../js/data/manager/iframe-index-data.js"></script>
	<script type="text/javascript" src="../js/util/page_head_main.js"></script>
	<style>
		.div-select{
			width: 80px;
			height: 30px;
			border-left: 0px;
			border-top: 0px;
			border-right: 0px;
		}
		.div-button-one{
			width: 100px;
			height: 30px;
			border-left: 0px;
			border-top: 0px;
			border-right: 0px;
			border-bottom-color:#93D1FF;
			text-align: center;
		}
		.div-button-tow{
			width: 100px;
			height: 30px;
			border-left: 0px;
			border-top: 0px;
			border-right: 0px;
			text-align: center;
			background-color: white;
		}
		.div-button-three{
			width: 300px;
			height: 30px;
			border-left: 0px;
			border-top: 0px;
			border-right: 0px;
			text-align: center;
		}
		.div-button-four{
			width: 70px;
			height: 35px;
			border-left: 0px;
			border-top: 0px;
			border-right: 0px;
			text-align: center;
			background-color: #93D1FF;
			border-bottom: 0px ;
			border-radius:25px;
			 	cursor:pointer;
		}
		.div-select-tow{
			width: 180px;
			height: 30px;
			border-left: 0px;
			border-top: 0px;
			border-right: 0px;
		}
	</style>
 	</head>
  
  <body style="background-color: white;" >
   <div style="width: 100%;float: left;">
		<div class="row-div-mian" id="headDiv"></div>
 	</div>
  
  <div style="width: 100%;float: left; min-width:1200px;">
		<div style="width: 100%;align-content: center;">
			<div style="margin-left: 50%;color: #1E9FFF;"> 
				<h1> </h1>
			</div>
		</div>
  </div>
  <div style="width: 100%;float: left; min-width:1200px;">
  	<div style="float: left;margin-left: 20px;margin-top: 10px;">
     	 <input value="第一页" type="button" name="" onclick="onePage()"    class="div-button-one"/>
     </div>
  	<div style="float: left;margin-left: 20px;margin-top: 10px;">
     	 <input value="上一页" type="button" name="" onclick="topPage()"    class="div-button-one"/>
     </div>
     <div style="float: left;margin-left: 30px;margin-top: 10px;">
     		<input type="text" value="0" id="page" class="div-button-one"/>
     </div>
       <div style="float: left;margin-left: 30px;margin-top: 10px;">
     		  <input type="button" value="0" disabled="disabled" id="pageCount" class="div-button-one"/>
     </div>
     
      <div style="float: left;margin-left: 20px;margin-top: 10px;">
     	 <input value="下一页" type="button" name=""  onclick="nextPage()"   class="div-button-one"/>
     </div>
     <div style="float: left;margin-left: 20px;margin-top: 10px;">
     	 <input value="最后一页" type="button" name="" onclick="lastPage()"    class="div-button-one"/>
     </div>
     <div style="float: left;margin-left: 20px;margin-top: 10px;">
     	 <input value=" " name=""  id="size" class="div-button-one"/>
     </div>
     
    
     <div style="float: left;margin-left: 10px;margin-top: 10px;">
     		<div style="float: left;margin-left: 5px;">
     			  <input type="text" value="" id="seach"   class="div-button-three" />
     		</div>
     		<div style="float: left;margin-left: 10px;">
     			<button onclick="seach()" class="div-button-four">查询</button>
     		</div>
	     <input type="hidden" id="hid" value="" />
     </div>
     
  </div>
  
   <div style="width: 100%;float: left; min-width:1200px;">
   	<div style="margin-left: 30px;float: left;margin-top: 10px;" >
   		  <select id="runTime" name="" class="div-select-tow">
      	<option value="1">1秒request1次</option>
      	<option value="2">2秒request1次</option>
      	<option value="3">3秒request1次</option>
      	<option value="4">4秒request1次</option>
      	<option value="5">5秒request1次</option>
      	<option value="6">6秒request1次</option>
      </select>
   	</div>
     <div style="float: left;margin-top: 10px;margin-left: 10px;">
     	开启:<input type="radio" name="ts" value="s" id="start"  />
    	     停止: <input type="radio"  name="ts" value="e" id="end" checked="checked"/>
     </div> 
      <div style="float: left;margin-top: 5px;margin-left: 10px;">
      	<input type="button" name="" id="" value="执行"    onclick="execueTime()" class="div-button-four"/>
     </div> 
  </div>
  <div style="width: 100%;float: left; min-width:1200px;">
  	<div style="float: left;margin-left: 30px;margin-top: 10px;">
     		 <span class="layui-badge" id="dis" style="margin-top: 5px;"> </span>
    </div>
    <div style="float: left;margin-top: 14px; ">
     		   <span style="margin-left: 10px;">JSON 数据：</span>
     		   <span id="jsonsCount" style="margin-left:1px;color: red;" ></span>
     		   <span  style="margin-left:1px;" >条</span>
     		   <a href="javascript:(0)" onclick="showJsons()" style="color: blue;" >查看</a>
    </div>
    <div style="float: left;margin-top: 10px;margin-left: 100px;display: none;" id="jsons" >
     		  
    </div>
  </div>
  <div style="width: 100%;height: 700px;float: left; min-width:1200px;font-size: 15px;overflow:auto;margin-top: 10px;" id="show">
  	
  	
  </div>
  </body>
  <script type="text/html" id="templatePage">
  	<$for(var i=0;i<count;i++){$>
  		 <$if(i==0){$>
  		 	 <option value="<$=i$>" selected="selected"> <$=i$></option>
  		 	<$}else{$>
  		 		 <option value="<$=i$>"><$=i$></option>
				<$}$>
  	<$}$>
  </script>
  <script type="text/html" id="templateShow">
  	
  	 	<$for(var i=0;i<list.length;i++){$>
	  	 	<div style="margin-top: 5px;margin-left: 10px;" id="div_<$=i$>">
	  	 		 <span>
							<$=list[i]$>
	  	 		 </span>
	  	 	</div>
  	 	<$}$>
  </script>
  <script type="text/html" id="templateJsons">
  	<$for(var i=0;i<jsons.length;i++){$>
  		<div style="  margin-top: 10px;border-bottom: 1px solid gainsboro; ">
  				<a href="json.html?jsons=<$=jsons[i]$>" style="cursor:pointer;color: #0C0C0C;font-size: 20px;" target="_blank"><$=jsons[i]$></a>
  		</div>
  	<$}$>
  </script>
  <script type="text/html" id="templateHead">
			<span >
				 <a href="javascript:void(0)" onclick="clickServers()" style="color: #999!important;">日志管理</a>-
				 <a href="#" > <$=data$></a>
				 <a href="" style="margin-left: 5px;">
				  	<i class="layui-icon layui-anim layui-anim-rotate ">ဂ</i>
				 </a> 
			</span>
	</script>
   <script type="text/javascript">
 		head({data:"實時日志監控"});	
   </script>
   <script type="text/javascript">
   var page=0;
   var size=10000;
   var seachs="";
   //var ip="192.168.18.10";//"47.100.32.85"
   var ip="192.168.18.154";
   //var staPath="D:/Apache Software Foundation/Tomcat 7.0/service.log";
   var staPath="D:/service.log";
		queryToDay();
		
 		 function showInfo(page,size,path){
 		 		var url="http://"+ip+":8080/yp-resource/tomcatLogInfoController/queryLogPage?";
 			 	var rexVal=queryRuleData("rulesInfo-rex");
 		 	 	rexVal=encryptByDES(rexVal,"dyoD0AwL");
 		 	 rexVal=rexVal.replace(/\+/g,",");
 		 	 
 		 	 var pSize=$("#size").val();
 		 		  if(pSize==null||pSize==" "){
 		 		 	 	$("#size").val(size);
 		 		  }
 		 		  	 
 		 		$.getJSON(url+"path="+path+"&page="+page+"&size="+size+"&encode=GBK&ypcollBack=?&saltEC=lgMxEb1UcEwBmHwSwQ9j8UviIOJdhD7MR9uygiFAs8o=&rexval="+rexVal,function(data){
 		 			var valse=data.result;
 		 			console.log(data)
 		 			if(seachs!=""){
						var reg = "/"+seachs+"/g"
 		 				valse=valse.replace(eval(reg),"<span style='color:#2bcaa2'>"+seachs+" </span>");
 		 			}
 		 			valse=valse.replace(/\\"/g,"\"");
 		 			valse=valse.replace(/\"{/g,"{");
 		 			valse=valse.replace(/}\"/g,"}");
 		 		  var val={
 		 		  	val:valse,
 		 		  	list:data.list,
 		 		  	jsons:data.jsons
 		 		  };
 		 		  var count=data.count;
 		 		  var ddd=count/size;
 		 		 
 		 		  var counts={count:ddd};
 		 		  $("#dis").text(count);
 		 		  
 		 		   	var html1 = template('templateShow', val);
 		 		   	 document.getElementById('show').innerHTML = html1;
 						
 						document.getElementById("jsonsCount").innerHTML=val.jsons.length;
						var html2=template('templateJsons', val);
						document.getElementById("jsons").innerHTML=html2;
	


 		 		   		var showDiv= document.getElementById('show');;
				  	 showDiv.scrollTop=showDiv.scrollHeight;
				  	 
				  	 	document.getElementById('pageCount').value = parseInt(ddd);
				  	 	
//				   	var html = template('templatePage', counts);
//				  	document.getElementById('page').innerHTML = html;
 		 		});
 		 }
 		 
 		 function queryToDay(){
 		 	 var oldPath= $("#hid").val();
 		 	if(oldPath!=""){
 		 		showInfo(page,size,oldPath);
 		 	}else{
 		 		var url="http://"+ip+":8080/yp-resource/tomcatLogInfoController/queryLogToDay?";
 		 		$.getJSON(url+"ypcollBack=?&saltEC=lgMxEb1UcEwBmHwSwQ9j8UviIOJdhD7MR9uygiFAs8o=",function(data){
 		 		  var path=	data.result;
 		 		  if(path==null||path==""){
 		 		  	staPath=staPath.replace(/\\/g,"%5C");
 		 		 	 $("#hid").val(staPath);
 		 		 	 	showInfo(page,size,staPath);
 		 		  }else{
 		 		  	path=path.replace(/\\/g,"%5C");
 		 		 	 $("#hid").val(path);
 		 		 	 	showInfo(page,size,path);
 		 		  }
 		 		 	 
 		 		});
 		 	}
 				 	
 		 }
 		 function seach(){
 		 		  page=$("#page").val();
 		 		 size=$("#size").val();
 		 	 	seachs=$("#seach").val();
 		 		queryToDay();
 		 }
 		 
 		 var terval=null;
 		 function execueTime(){
 		 	  var val = $('input[name="ts"]:checked').val();
 		 	  var runTime=$("#runTime").val();
 		 	  runTime=runTime*1000;
 		 		if(val=="e"){
 		 			 clearInterval(terval) ;
 		 			// setTimeout('seach()',runTime)
 		 		}
 		 		if(val=="s"){
 		 		terval=	setInterval('seach()',runTime)
 		 		}
 		 }
 	function queryRuleData(str){
 			var rulesInfo =	window.localStorage.getItem(str)
 			var rulesData=new Array();
    		if(rulesInfo!=""&&rulesInfo!=null){
    			rulesData=JSON.parse( rulesInfo );
    		}
    		var val={val:rulesData};
    		 var arrs=JSON.stringify(val);
			return arrs.toString();
		}
 	
 	function topPage(){
 		page=$("#page").val();
 		$("#page").val(	parseInt(page)-1);
 		seach();
 	}
 	
 	function nextPage(){
 		page=$("#page").val();
 		$("#page").val(	parseInt(page)+1);
 		seach();
 	}
 	
 	function onePage(){
 			$("#page").val(	0);
 		seach();
 	}
 	function lastPage(){
 			page=$("#pageCount").val();
 		$("#page").val(	parseInt(page));
 		seach();
 	}
 	function showJsons(){
 		layer.open({type:1,content:$('#jsons').html(), area: ['90%', '90%'],title: ['jsons', 'font-size:16px;']});
 	}
    
    
   </script>
   
</html>
